﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Principal;

namespace ATest.Bll
{
    public abstract class BaseItem
    {

        protected string GetLoginName()
        {
            var tmp = GetCurrentIdentity();
            if (tmp != null)
            {
                return tmp.Name;
            }
            else
            {
                throw new ApplicationException("User Not Login In");
            }

        }

        protected IIdentity GetCurrentIdentity()
        {
            if (System.Web.HttpContext.Current != null)
            {
                return System.Web.HttpContext.Current.User.Identity;
            }
            else
            {
                return System.Threading.Thread.CurrentPrincipal.Identity;
            }
        }
    }
}
